# Maintainer: Jan Alexander Steffens (heftig) <jan.steffens@gmail.com>
# Contributor: Ionut Biru <ibiru@archlinux.org>

pkgbase=pygobject
pkgname=(python-gobject python2-gobject pygobject-devel)
pkgver=3.30.1
pkgrel=3
pkgdesc="Python Bindings for GLib/GObject/GIO/GTK+"
url="https://wiki.gnome.org/Projects/PyGObject"
arch=(x86_64)
license=(LGPL)
depends=(gobject-introspection-runtime)
makedepends=(python{,2}-cairo gobject-introspection git meson)
optdepends=('cairo: Cairo bindings')
_commit=85baa83ca780b4aae89ce5f25b1186ee3790b828  # tags/3.30.1^0
source=("git+https://gitlab.gnome.org/GNOME/pygobject.git#commit=$_commit")
sha256sums=('SKIP')

pkgver() {
  cd $pkgbase
  git describe --tags | sed 's/-/+/g'
}

prepare() {
  cd $pkgbase
}

_build() (
  arch-meson $pkgbase build-$1 -D python=/usr/bin/$1
  ninja -C build-$1
)

_package() {
  DESTDIR="$pkgdir" meson install -C build-$1
  $1 -m compileall -d /usr/lib "$pkgdir/usr/lib"
  $1 -O -m compileall -d /usr/lib "$pkgdir/usr/lib"
}

build() {
  _build python
  _build python2
}

package_python-gobject() {
  depends=("pygobject-devel=$pkgver" python)

  _package python

### Split -devel
  mkdir -p "$srcdir/devel"
  mv "$pkgdir"/usr/{include,lib/pkgconfig} "$srcdir/devel"
}

package_python2-gobject() {
  pkgdesc="${pkgdesc/Python/Python2}"
  depends=("pygobject-devel=$pkgver" python2)

  _package python2

### Remove -devel
  rm -r "$pkgdir"/usr/{include,lib/pkgconfig}
}

package_pygobject-devel() {
  pkgdesc="Common development files for pygobject"
  optdepends=()

  mkdir -p "$pkgdir/usr/lib"
  mv devel/include "$pkgdir/usr"
  mv devel/pkgconfig "$pkgdir/usr/lib"
}

# vim:set sw=2 et:
